class PagerHelper {
    constructor(href, options = [10, 20, 50], pageNum = 1, pageSize = 10) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;

        this.options = options;
        this.href = href;
    }

    setCount(count) {
        //记录总数
        this.count = count;

        if (this.count % this.pageSize === 0) {
            this.total = Math.floor(this.count / this.pageSize);
        } else {
            this.total = Math.floor(this.count / this.pageSize) + 1;
        }

        //删除一整页数据时，pageNum要调整为第一页
        if (this.pageNum > this.total) {
            this.pageNum = 1;
        }

        this.firstNum = 1;//首页码1
        this.lastNum = this.total;//尾页码
        this.preNum = this.pageNum - 1;//上一页页码
        if (this.preNum <= 0) {
            this.preNum = 1;
        }
        this.nextNum = this.pageNum + 1;//下一页页码
        if (this.nextNum >= this.total) {
            this.nextNum = this.total;
        }

    }
}

module.exports = new PagerHelper();